//
//  WJQStyleLightCollectionViewCell.m
//  TripTogether
//
//  Created by dllo on 15/12/28.
//  Copyright © 2015年 王军岐. All rights reserved.
//

#import "WJQStyleLightCollectionViewCell.h"

@interface WJQStyleLightCollectionViewCell ()

@property (nonatomic, strong) UIImageView *imageV;
@property (nonatomic, strong) UILabel *titleL;

@property (nonatomic, strong) UILabel *timeL;
@property (nonatomic, strong) UILabel *addL;

@property (nonatomic, strong) UIImageView *userImageV;
@property (nonatomic, strong) UILabel *userName;

@end


@implementation WJQStyleLightCollectionViewCell
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createSubView];
    }
    return self;
}
-(void)createSubView
{
    _imageV = [UIImageView new];
    _imageV.backgroundColor = [UIColor clearColor];
    _imageV.layer.masksToBounds = YES;
    _imageV.layer.cornerRadius = 4.f;
    _imageV.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_imageV];
    
    [_imageV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.edges.mas_equalTo(@0);
    }];
    
    
    UIImageView *backImageV = [UIImageView new];
    backImageV.image = [UIImage imageNamed:@"dest_around_shadow.png"];
    backImageV.layer.masksToBounds = YES;
    backImageV.layer.cornerRadius = 4.f;
    backImageV.alpha = 0.5;
//    backImageV.contentMode = UIViewContentModeScaleAspectFill;
    [_imageV addSubview:backImageV];
    
    [backImageV mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.top.bottom.mas_equalTo(@0);
        make.right.mas_equalTo(self.contentView).multipliedBy(0.6);
    }];
    
    
    
    _titleL = [UILabel new];
//    _titleL.backgroundColor = [UIColor lightGrayColor];
    _titleL.textColor = [UIColor whiteColor];
    _titleL.numberOfLines = 0;
    _titleL.font = [UIFont fontWithName:@"Bradley Hand" size:19.f];
    [self.contentView addSubview:_titleL];
    
    [_titleL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(@15);
//        make.height.mas_equalTo(@30);
        make.left.mas_equalTo(@15);
        make.right.mas_equalTo(@0);
    }];
    
    UIView *view = [UIView new];
    view.backgroundColor = [UIColor colorWithRed:0.32 green:0.75 blue:0.81 alpha:1];
    view.layer.masksToBounds = YES;
    view.layer.cornerRadius = 2.f;
    [self.contentView addSubview:view];
    
    [view mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.size.mas_equalTo(CGSizeMake(4, 25));
        make.left.mas_equalTo(_titleL.mas_left).offset(2);
        make.top.mas_equalTo(_titleL.mas_bottom).offset(2);
    }];
    
    _timeL = [UILabel new];
    _timeL.backgroundColor = [UIColor clearColor];
    _timeL.textColor = [UIColor whiteColor];
    _timeL.font = [UIFont fontWithName:@"Zapf Dingbats" size:12.f];
    _timeL.font = [UIFont boldSystemFontOfSize:13.f];
    [self.contentView addSubview:_timeL];
    
    
    
    _addL = [UILabel new];
    _addL.backgroundColor = [UIColor clearColor];
    _addL.textColor = [UIColor colorWithRed:0.93 green:0.93 blue:0.93 alpha:1];
    _addL.font = [UIFont fontWithName:@"Zapf Dingbats" size:11.f];
    _addL.font = [UIFont boldSystemFontOfSize:11.f];
    [self.contentView addSubview:_addL];
    
    
    [_timeL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(view.mas_right).offset(7);
        make.right.mas_equalTo(_titleL.mas_right);
        make.top.mas_equalTo(view.mas_top);
        make.height.equalTo(_addL);
    }];
    
    
    [_addL mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(_timeL.mas_left);
        make.right.mas_equalTo(_timeL.mas_right);
        make.top.mas_equalTo(_timeL.mas_bottom).offset(3);
        make.bottom.equalTo(view.mas_bottom);
        make.height.equalTo(_timeL);

        
    }];
    
    _userImageV = [[UIImageView alloc] initWithFrame:CGRectMake(15, 200 - 35 - 15, 35, 35)];
    _userImageV.backgroundColor = [UIColor clearColor];
    _userImageV.layer.masksToBounds = YES;
    _userImageV.layer.cornerRadius = _userImageV.frame.size.width / 2.f;
    _userImageV.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_userImageV];
    
    

    
    _userName = [UILabel new];
    _userName.backgroundColor = [UIColor clearColor];
    _userName.font = [UIFont fontWithName:@"Devanagari Sangam MN" size:13.f];
    _userName.textColor = [UIColor whiteColor];
    [self.contentView addSubview:_userName];
    
    [_userName mas_makeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(@(15 + 35 + 10));
        make.right.mas_equalTo(@0);
        make.height.mas_equalTo(@15);
        make.bottom.mas_equalTo(@(-(15 + (35 - 15) / 2.f)));
    }];

}
- (void)setTripMod:(WJQTripModel *)tripMod
{
    [_imageV sd_setImageWithURL:[NSURL URLWithString:tripMod.cover_image] placeholderImage:PICHOLDEER];
    
    _titleL.text = tripMod.name;
    
    NSString *timeStr = [tripMod.first_day stringByReplacingOccurrencesOfString:@"-" withString:@"."];
    _timeL.text = [NSString stringWithFormat:@"%@   %@天   %@浏览", timeStr, tripMod.day_count, tripMod.view_count];
    
    _addL.text = tripMod.popular_place_str;
    
    [_userImageV sd_setImageWithURL:[NSURL URLWithString:tripMod.avatar_m] placeholderImage:PICHOLDEER];
    
    _userName.text = tripMod.userName;
}
@end
